{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a3a64a4a",
   "metadata": {},
   "source": [
    "---\n",
    "* 日期：2022-11-23\\week14（周三）\n",
    "* 课程：python\n",
    "* 记录人：zeng\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4f88a5f9",
   "metadata": {},
   "source": [
    "# 1. 函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "af08f707",
   "metadata": {},
   "outputs": [],
   "source": [
    "def greet_user():\n",
    "    \"\"\"用户问候语\"\"\"\n",
    "    print(\"hello world\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "51a752f0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world\n"
     ]
    }
   ],
   "source": [
    "greet_user()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "b613fabd",
   "metadata": {},
   "outputs": [],
   "source": [
    "def greet_user(username):\n",
    "    \"\"\"用户问候语\"\"\"\n",
    "    print(\"hello\",username)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "70973a2b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello 李华\n"
     ]
    }
   ],
   "source": [
    "greet_user(username=\"李华\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "02994828",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 函数的意义 1：重复使用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "1e99661d",
   "metadata": {},
   "outputs": [],
   "source": [
    "def nfu_news_url(类别,page):\n",
    "    for page in range(page):\n",
    "        print(\"https://www.nfu.edu.cn/\" + 类别 + \"/index\" + str(page) + \".htm\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a321d606",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/tzgg/index0.htm\n",
      "https://www.nfu.edu.cn/tzgg/index1.htm\n",
      "https://www.nfu.edu.cn/tzgg/index2.htm\n",
      "https://www.nfu.edu.cn/tzgg/index3.htm\n",
      "https://www.nfu.edu.cn/tzgg/index4.htm\n",
      "https://www.nfu.edu.cn/tzgg/index5.htm\n",
      "https://www.nfu.edu.cn/tzgg/index6.htm\n",
      "https://www.nfu.edu.cn/tzgg/index7.htm\n",
      "https://www.nfu.edu.cn/tzgg/index8.htm\n",
      "https://www.nfu.edu.cn/tzgg/index9.htm\n",
      "https://www.nfu.edu.cn/tzgg/index10.htm\n",
      "https://www.nfu.edu.cn/tzgg/index11.htm\n",
      "https://www.nfu.edu.cn/tzgg/index12.htm\n",
      "https://www.nfu.edu.cn/tzgg/index13.htm\n",
      "https://www.nfu.edu.cn/tzgg/index14.htm\n"
     ]
    }
   ],
   "source": [
    "nfu_news_url(\"tzgg\",15)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "0cdcee07",
   "metadata": {},
   "outputs": [],
   "source": [
    "### 实战\n",
    "def NFU_NEWS_URL(分类,页码):\n",
    "    \"\"\"广州南方学院新闻页面URL数据\n",
    "       分类包含：【学校要闻：xxyw，校园动态：xydt,通知公告：tzgg，招投标：ztd】\n",
    "       页码包含：【113，106，37，27】\n",
    "    \"\"\"\n",
    "    for i in range(页码):\n",
    "        print(\"https://www.nfu.edu.cn/\" + 分类 + \"/index\" + str(i) + \".htm\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "38896889",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function NFU_NEWS_URL in module __main__:\n",
      "\n",
      "NFU_NEWS_URL(分类, 页码)\n",
      "    广州南方学院新闻页面URL数据\n",
      "    分类包含：【学校要闻：xxyw，校园动态：xydt,通知公告：tzgg，招投标：ztd】\n",
      "    页码包含：【113，106，37，27】\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(NFU_NEWS_URL)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ed133a7f",
   "metadata": {},
   "source": [
    "# 2. 函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "50981907",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'college_url_crawl'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_10644/4191694743.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mcollege_url_crawl\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'college_url_crawl'"
     ]
    }
   ],
   "source": [
    "import college_url_crawl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e9a28f46",
   "metadata": {},
   "outputs": [],
   "source": [
    "help"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "61ede396",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4a8064d0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7ceb8831",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6b0ed867",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c8b66c2d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "033c0a22",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
